<?php
if(isset($_POST['data']))
{
	require("includes/basic.php");
	//$did=$_POST['did'];
	//echo $_POST['data'];
	$d=$_POST['data'];
	$id= split(',',$d);
	foreach($id as $a => $b)
	{
		$close=mysql_query("update task_status set task_status=2 where task_id=$b");	
	}
	
}


if(isset($_POST['pid']))
{
	
	require("includes/basic.php");
	$user=$userId;
	$q=$_POST["pid"];
	
	$sql=mysql_query("select * from task_master t, task_status ts, task_assigned_to a, phase_master s, user_master u where a.task_assigned_to=u.user_id and t.task_id=ts.task_id and t.task_id=a.task_id and u.vendor_id=$user and t.project_id=$q and t.record_status='Y' and s.phase_id=a.phase_id");
	
}
else
{
	$user=$userId;
	$sql=mysql_query("select * from task_master t, task_status ts, task_assigned_to a, user_master u where a.task_assigned_to=u.user_id and t.task_id=ts.task_id and t.task_id=a.task_id  and u.vendor_id=$user and t.record_status='Y'");

}	
$sr=1;
$user=$userId;
$noOfTasks=mysql_num_rows($sql);
?>
<form id='viewmyprojects' name='viewmyprojects' action='' method='post'>
<table width='100%' cellpadding='1' cellspacing='0' class='list'>
	<tr>
		<th  style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Sr. no</span>
			</div>
		</th>
		<th  style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Open</span>
			</div>
		</th>
		<th  style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link">Task Title</span>
			</div>
		</th>
		<th  style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Task Description</span>
			</div>
		</th>
		<th  style='white-space: nowrap;' align='center'>
			<span class="link">Phase</span>
		</th>
		<th  style='white-space: nowrap;'>
			<span class="link">Module</span>
		</th>
		<th  style='white-space: nowrap;' align='center'>
			<span class="link">Priority</span>
		</th>
		<th  style='white-space: nowrap;'>
			<span class="link">Time Alloted</span>
		</th>
		<th  style='white-space: nowrap;'>
			<span class="link">Resource</span>
		</th>
		<th  style='white-space: nowrap;'>
			<span class="link">Status</span>
		</th>
		<th  style='white-space: nowrap;'>
			<span class="link">Status Description</span>
		</th>
		

		<th width='0' class='select'>
			<input type='checkbox' class='checkbox' id='listSelectAll' name='listSelectAll'>
		</th>
	</tr>
	<?php
		while($rows=mysql_fetch_array($sql))
		{
			$taskid=$rows['task_id'];
			$title=$rows['task_title'];
			$taskdesc=$rows['task_description'];
			$priority=$rows['task_priority'];
			$phaseid=$rows['phase_id'];
			$moduleid=$rows['module_id'];
			$taskdesc=$rows['task_description'];
			$timealloted=$rows['estimated_time']." hr";
			$statusdesc=$rows['status_description'];
			$status=$rows['task_status'];
			$resource=$rows['first_name']." ".$rows['last_name'];
	?>
	<tr>
	<td style='text-align:center;'><?php echo $sr; ?></td>
	<td style='text-align:center;'><a href="task-details.php?t=<?php echo $taskid; ?>"><img src='images/open-project.png' alt='Open Task' title='Open Task'></a></td>
	<td  style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link"><?php echo $title; ?></span>
			</div>
	</td>
	<td style='white-space: nowrap;'>
		<div style='display:block; '>
			<span class="link linkdisabled"><?php echo $taskdesc; ?></span>
		</div>
	</td>
	
	<td  style='white-space: nowrap;'>
	<?php 
	$sq="select * from phase_master where phase_id=$phaseid";
				$sqres=mysql_query($sq);
				while($phas=mysql_fetch_array($sqres))
			{
				extract($phas);
			echo $phase;
			}
			?>
			</td>

			<td  style='white-space: nowrap;'>
			<?php
		$sqmod="select * from module_master where module_id=$moduleid";
				$sqmodres=mysql_query($sqmod);
				while($mod=mysql_fetch_array($sqmodres))
			{
				extract($mod);
			echo $module;
			}
			?>
			</td>
			<td  style='white-space: nowrap;' align='center'>
		<span class="link"><?php echo $priority; ?></span>
	</td>
	<td  style='white-space: nowrap;'>
		<span class="link"><?php echo $timealloted; ?></span>
	</td>
	<td  style='white-space: nowrap;'>
		<span class="link"><?php echo $resource; ?></span>
	</td>
	<td  style='white-space: nowrap;'>
		<span class="link"><?php if ($status==1) { echo "open"; } else { echo "Closed"; } ?></span>
	</td>
	<td  style='white-space: nowrap;'>
		<span class="link"><?php echo $statusdesc; ?></span>
	</td>
	
	<td style='text-align:center;'><input type='checkbox' value='<?php echo $taskid;?>' id='chkName' name='chkName'></td>
	</tr>
	<?php
		$sr++;
		}
	?>
	</table>

	</form>